var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

function find(collection,query,callback){
    MongoClient.connect(url,{useNewUrlParser:true}, function(err, db) {
        if (err) throw err;
        var dbo = db.db("mongo");
        var where  =  query
        // console.log(where)
        dbo.collection(collection).find(where).toArray(function(err, result) { // 返回集合中所有数据
            if (err) throw err;
            callback(result);
            db.close();
        });
    });
}
// find('Commit',{},function(e){console.log(e)})
module.exports =  find